package com.wecan.components.pay.controller;

import com.wecan.api.pay.PayInsideData;
import com.wecan.api.saasdata.OrderData;
import com.wecan.base.PO.Order;
import com.wecan.base.controller.BaseController;
import com.wecan.components.pay.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author liuzhihao
 * @Date 2022.04.08
 * @Version ${version}
 * @Description ${description}
 */
@RestController
@RequestMapping(value = "/pay/inside")
public class PayInsideController extends BaseController implements PayInsideData {

    @Autowired
    private PayService payService;

    @Autowired
    private OrderData orderData;

    @Override
    public boolean refundHalf(@RequestParam("id") Long id, @RequestParam("reason") String reason) {
        Order order = orderData.queryById(id);
        if (order == null) {
            return false;
        }
        return payService.refund(order, reason);
    }
}
